﻿//
// Created by Administrator on 2020/9/8.
//

#include "Person.h"


Person::Person(const char *name, const int age) {

    int nameSize = std::strlen(name);

    this->name = new char[nameSize + 1];
    std::strcpy(this->name, name);
    this->age = age;
}

Person::~Person() {
    delete[] this->name;
    std::cout << "free person" << std::endl;
}

void Person::toString() {
    using std::cout;
    using std::endl;

    cout << "Person [name:" << this->name << ", age:" << this->age << "]" << endl;
}

std::ostream &operator<<(std::ostream &os, const Person &person) {
    os << "Person << [name:" << person.name << ", age:" << person.age << "]\n";
    return os;
}